<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="<c:url value='/static/jquery/jquery-1.9.1.min.js'/>" type="text/javascript"></script>
<script type="text/javascript" src="<c:url value='/static/themes/js/jquery.datatables.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/static/datetimepicker/js/bootstrap-datetimepicker.js'/>"charset="UTF-8"></script>		
<title>平台资金明细</title>
</head>
<body>
	<div class="panel panel-default bk-bg-white">
		<div class="panel-body">
		<form class="form-horizontal" id="searchForm" method="post" action="#">
			<div class="row">
				<div class="form-group col-sm-4">
					<label  class="col-sm-4 control-label">生财ID：</label> 
					<div class="col-sm-8">
						<input type="text" class="form-control" name="userId" id="userId"  placeholder="生财ID">
					</div>
				</div>
				<div class="form-group col-sm-4">
					<label  class="col-sm-4 control-label">账户类型：</label> 
					<div class="col-sm-8">
						<select id="changeAccount" name="changeAccount" class="form-control">
							<option value="">所有类型</option>
							<option value="0_0">商家基本账户</option>
							<option value="0_1">商家冻结账户</option>
							<option value="1_0">买手基本账户</option>
							<option value="1_1">买手生财账户</option>
						</select>
					</div>
				</div>
				<div class="form-group col-sm-4">
					<label  class="col-sm-4 control-label">收支类型：</label> 
					<div class="col-sm-8">
						<select id="paymentsDirection" name="paymentsDirection" class="form-control">
							<option value="">所有类型</option>
							<option value="0">支</option>
							<option value="1">收</option>
						</select>
					</div>
				</div>
			</div>
			<div class="row">
				
				<div class="form-group col-sm-4">
					<label  class="col-sm-4 control-label">任务ID：</label> 
					<div class="col-sm-8">
   						<input type="text" class="form-control" name="associateTaskID" id="associateTaskID"  placeholder="任务ID">
					</div>
				</div>
				<div class="form-group col-sm-4">
					<label  class="col-sm-4 control-label">变动金额：</label> 
					<div class="col-sm-8">
						<input type="text" class="form-control" name="minMoneyAmount" id="minMoneyAmount"  placeholder="变动金额最小值">
						
					</div>
				</div>
				<div class="form-group col-sm-4">
					<label  class="col-sm-1 control-label">-</label>
					<div class="col-sm-8">
   						<input type="text" class="form-control" name="maxMoneyAmount" id="maxMoneyAmount"  placeholder="变动金额最大值">
					</div>
				</div>
			</div>
			<div class="row">
				<div class="form-group col-sm-4">
					<label  class="col-sm-4 control-label">发生日期：</label> 
					<div class="col-sm-8">
   						<input class="input-append date form_datetime form-control" name="startChangeDate" id="startChangeDate" >
						    <span class="add-on"><i class="icon-remove"></i></span>
						    <span class="add-on"><i class="icon-calendar"></i></span>
					</div>
				</div>
				<div class="form-group col-sm-4">
					<label  class="col-sm-1 control-label">-</label>
					<div class="col-sm-8">
   						<input class="input-append date form_datetime form-control" name="endChangeDate" id="endChangeDate" >
						    <span class="add-on"><i class="icon-remove"></i></span>
						    <span class="add-on"><i class="icon-calendar"></i></span>
					</div>
				</div>
			</div>
			<div class="form-group col-sm-12" style="padding-bottom: 15px; text-align: center;">
					<button id="search" type="button" class="btn btn-primary glyphicon glyphicon-search"> 搜索</button>
					<button id="report" type="button" class="btn btn-success glyphicon glyphicon-download"> 批量导出</button>
			</div>
		</form>	
		</div>
	</div>
	<!-- panel-body -->
	<div id="message"></div>
	<!-- panel -->
	<div class="panel panel-default">
		<div class="panel-body">
			<div class="table-responsive">
				<div id="table1_wrapper" class="dataTables_wrapper no-footer">
					<table id="table" class="display nowrap" cellspacing="0" width="100%">
						<thead>
							<tr role="row">
								<th>时间</th>
								<th>生财ID</th>
								<th>账户类型</th>
								<th>收/支</th>
								<th>变动金额</th>
								<th>变动原因</th>
								<th>关联账单ID</th>
								<th>关联任务ID</th>
								<th>账户余额</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
		<div id="page">
			
		</div>
	</div>

	<script type="text/javascript">
	
	
	$(function($) {
		//日期控件
		$('#startChangeDate').datetimepicker({
			language : 'zh-CN',
			format : 'yyyy-mm-dd hh:ii', 
			autoclose : true,
			todayBtn : true,
			minuteStep : 10
		}).on('changeDate', function (ev) {
			var starttime = $(this).val();
			$('#endChangeDate').datetimepicker('setStartDate',starttime);
            $(this).datetimepicker('hide');  
        });
		
		$('#endChangeDate').datetimepicker({
			language : 'zh-CN',
			format : 'yyyy-mm-dd hh:ii',
			autoclose : true,
			todayBtn : true,
			minuteStep : 10
		}).on('changeDate', function (ev) {
			var time = $(this).val();
			$('#startChangeDate').datetimepicker('setEndDate',time);
            $(this).datetimepicker('hide');  
        });
		
		function doSearch(){
			
			var table = $('#table').DataTable({
		        "processing": true,
		        "serverSide": true,
		        "bLengthChange": false,
		        "bFilter": false,
		        "bSort":false,
		        "bDestroy":true,
		        "sScrollX": "100%",
		        "sScrollY": "100%",
		        "language": {
		            "url": path+"/static/language_datatables.json"
		        },
		        "ajax": {
		            "url": path+"/capital/getDetailList",
		            "type": "POST",
		            "data":{
		                	"userId": $('#userId').val(),//生财ID
		                    "changeAccount": $('#changeAccount').val(),//账户类型
		                    "paymentsDirection": $('#paymentsDirection').val(),//收支类型
		                    "associateTaskID": $('#associateTaskID').val(),
		                    "minMoneyAmount": $('#minMoneyAmount').val(),
		                    "maxMoneyAmount": $('#maxMoneyAmount').val(),
		                    "startChangeDate": $('#startChangeDate').val(),
		                    "endChangeDate": $('#endChangeDate').val()
		            
		            } 
		        },
		        "columns": [
		            { "data": "changedate" ,"width": "18%"},
		            { "data": "userid" ,"width": "8%"},
		            { "data": "changeaccount","width": "13%" },
		            { "data": "paymentsdirection" ,"width": "8%"},
		            { "data": "moneyamount" ,"width": "10%"},
		            { "data": "changereason" ,"width": "10%"},
		            { "data": "associateorderformid","width": "12%"},
		            { "data": "associatetaskid","width": "12%"},
		            { "data": "changebalance","width": "10%"}
		        ],
		        "columnDefs": [
	                 
	                 {
	                     "render": function ( data, type, row ) {
	                    	 return dateTimeFormatter(data);
	                     },
	                     "targets": 0
	                 },
	                 {
	                     "render": function ( data, type, row ) {
	                    	 if(data=="0"){
	                    		 if(row.usertype=="0"){
	                    			 return "商家基本账户";
	                    		 }else{
	                    			 return "买手基本账户";
	                    		 }
	                    	 }else  if(data=="1"){
	                    		 if(row.usertype=="0"){
	                    			 return "商家冻结账户";
	                    		 }else{
	                    			 return "买手生财账户";
	                    		 }
	                    	 }else{return "";}
	                     },
	                     "targets": 2
	                 },
	                 {
	                     "render": function ( data, type, row ) {
	                    	 if(data=="0"){
	                    		 return "支";
	                    	 }else  if(data=="1"){
	                    		 return "收";
	                    	 }else{return "";}
	                     },
	                     "targets": 3
	                 },
	             ]

		    }); 
		};
		doSearch();
		
		//查询事件
		$('#search').click(function(){
			doSearch();
		});
		
		
		
		
	});
	//导出
	$('#report').click(function(){
		$('#searchForm').attr("action",path+"/capital/reportDetail");
		$('#searchForm').submit();
		$('#searchForm').attr("action","");
	});
	
	
	//显示消息
	function showmessage(msg,callback){
		$('#message').ucMessage({
			msg:msg,
			callback:callback
		});
	}
	 
	</script>
</body>
</html>